const {
  is
} = require('bpmnlint-utils')/** * A rule that checks, whether a gateway forks and joins * at the same time. */
module.exports = function() {
  function check(node, reporter) {
    if (!is(node, 'bpmn:Gateway')) {
      return
    }

    const incoming = node.incoming || []
    const outgoing = node.outgoing || []
    if (incoming.length > 1 && outgoing.length > 1) {
      reporter.report(node.id, 'Gateway forks and joins')
    }
  }

  return {
    check
  }
}
